<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/ajax.js" type="text/javascript"/>
</head>

<body>
<div>
    <h1>The Ajax 02 Page</h1>
    <fieldset>
        <legend>Ajax 表单请求</legend>
        <form>
        <input type=text" onblur="doCheck()" name="name" id="nameId" onfocus="doClear()">
        <button type="button" onclick="doSave()">Save</button>
        </form>
        <span id="result"></span>
    </fieldset>

</div>
</body>
<script>
    function doClear(){
        document.getElementById("result").innerHTML="";
    }
    function doSave(){
        let url="http://localhost:1314/doSave";
        let name=document.forms[0].name.value;
        let params=`name=${name}`;
        doAjaxPost(url,params,function (result){
          document.getElementById("result").innerHTML=result;
        })


    }
    function doCheck(){

        let name=document.forms[0].name.value;
        let url="http://localhost:1314/doCheck";
        doAjaxGet(url,`name=${name}`,function (result){
            document.getElementById("result").innerHTML=result;
        })
    }

</script>
</html>